﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StandardFramework
{
    [Serializable]
    public class BaseComponentPool : IEnumerable<BaseComponent>
    {
        List<BaseComponent> Components = new List<BaseComponent>();

        public void Update(float dtime)
        {
            foreach (BaseComponent c in Components)
            {
                c.Update(dtime);
            }
        }

        public BaseComponent this[int index]
        {
            get { return Components[index]; }
        }

        public void Add(BaseComponent Component)
        {
            Components.Add(Component);
        }

        public void Insert(int index, BaseComponent Component)
        {
            Components.Insert(index, Component);
        }

        public void RemoveAt(int index)
        {
            Components.RemoveAt(index);
        }

        public int IndexOf(BaseComponent Component)
        {
            return Components.IndexOf(Component);
        }

        public int Count
        {
            get { return Components.Count; }
        }

        #region IEnumerable<Component> Members

        public IEnumerator<BaseComponent> GetEnumerator()
        {
            return Components.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        #endregion
    }
}
